from airtest.core.api import *

from launch import App


class BaseObject:
    """
    对象层基类
    """

    def __init__(self):
        App.init_device()
        self.poco = App.start()

    def get_element_by_text(self, t):
        return self.poco(text=t)

    def get_element_by_parent(self, t):
        return self.poco(t)

    def get_element_parent_offspring(self, info):
        return self.poco(info[0]).offspring(info[1])

    # def get_daily_by_name(self, task_name):
    #     return self.poco(text=task_name).parent().sibling(name=r"btnColect (1)")


class BaseOperate:
    """
    操作层基类
    """
    # 点击
    def touch_goods(self, goods):
        touch(Template(goods))
